package com.xystoy.md5api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/md5")
public class Md5Controller {

    @Autowired
    private Md5Service md5Service;

    @GetMapping(value = "/hello")
    public String hello() {
        return "hello";
    }

    @GetMapping(value = "/get")
    public String get(@RequestParam(required = false) String cfName, @RequestParam String value) throws Exception {
        return md5Service.get(cfName, value);
    }

    @GetMapping(value = "/put")
    public String put(@RequestParam(required = false) String cfName, @RequestParam String key, @RequestParam String value) throws Exception {
        md5Service.put(cfName, key, value);
        return "1";
    }

    @GetMapping(value = "/delete")
    public String delete(@RequestParam(required = false) String cfName, @RequestParam String key) throws Exception {
        md5Service.delete(cfName, key);
        return "1";
    }
}
